/**
 * 
 */
package game;

/**
 * @author Jean-Baptiste BORIC
 *
 */
public class UnitType {

	private String name;
	private String[] images;
	
	private int movementRange;
	private String movementType;
	
	private WeaponType primaryWeaponType;
	
	private boolean canCapture;
	
	/**
	 * @param name
	 */
	public UnitType(String name) {
		super();
		this.setName(name);
		this.images = new String[5];
		this.setMovementRange(1);
	}

	/**
	 * @return Name of unit
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name Name of unit
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @param image ID of image
	 * @return Name of image
	 */
	public String getImage(int image) {
		return images[image];
	}

	/**
	 * @param image ID of image
	 * @param name Name of image
	 */
	public void setImages(int image, String name) {
		this.images[image] = name;
	}

	/**
	 * @return Movement range
	 */
	public int getMovementRange() {
		return movementRange;
	}

	/**
	 * @param movementRange Movement range
	 */
	public void setMovementRange(int movementRange) {
		if(movementRange < 1 || movementRange > 99) {
			throw new IllegalArgumentException("Movement range not between 1 and 99");
		}
		this.movementRange = movementRange;
	}

	/**
	 * @return Movement type
	 */
	public String getMovementType() {
		return movementType;
	}

	/**
	 * @param movementType Movement type
	 */
	public void setMovementType(String movementType) {
		this.movementType = movementType;
	}

	/**
	 * @return Primary weapon type
	 */
	public WeaponType getPrimaryWeaponType() {
		return primaryWeaponType;
	}

	/**
	 * @param primaryWeaponType Primary weapon type
	 */
	public void setPrimaryWeaponType(WeaponType primaryWeaponType) {
		this.primaryWeaponType = primaryWeaponType;
	}

	/**
	 * @return Can capture buildings
	 */
	public boolean canCapture() {
		return canCapture;
	}

	/**
	 * @param canCapture Capture flag
	 */
	public void setCanCapture(boolean canCapture) {
		this.canCapture = canCapture;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		String str = name + "\t";
		
		// Output image names
		for(int i = 0; i < 4; i++) {
			str += images[i] + "\t";
		}
		
		// Fill unused data
		str += "true\tfalse\tfalse\tfalse\t";
		
		str += movementType + "\t" + movementRange + "\t"; 
		str += "true\t" + primaryWeaponType + "\t";
		
		// Fill unused data
		str += "false\tx\t";
		str += "false\t0\t0\t";
		str += "false\tfalse\ttrue\t";
		str += "false\tfalse\tfalse";

		return str;
	}
}
